home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / sound / sndblst4.zip / RAWOUT.C < prev    next >
Text File  |  1993-12-11  |  2KB  |  69 lines

  1.  
  2. //------------------------------------------------------------------------------
  3. // Copyright (c) David Welch, 1993
  4. //------------------------------------------------------------------------------
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <conio.h>
  9.  
  10. #include "sb.h"
  11.  
  12. unsigned char ca;
  13. unsigned short ra;
  14. unsigned long la;
  15. FILE *fp;
  16. unsigned char gstring[80];
  17. unsigned long dLen;
  18. //------------------------------------------------------------------------------
  19. void main ( int argc, char *argv[] )
  20. {
  21.     if(argc<3)
  22.     {
  23.         printf("RAWOUT [d:][path]filename[.ext] samplerate\n");
  24.         exit(1);
  25.     }
  26.     if((fp=fopen(argv[1],"rb"))==0)
  27.     {
  28.         printf("Error opening file [%s]\n",argv[1]);
  29.         exit(1);
  30.     }
  31.     printf("FILE: [%s]\n",argv[1]);
  32.     sbinit();
  33.     sbmalloc();
  34.     fseek(fp,0L,2);
  35.     dLen=ftell(fp);
  36.     fseek(fp,0L,0);
  37.     ra=atoi(argv[2]);
  38.     printf("Samples Per Second %u\n",ra);
  39.     ca=256UL-(1000000UL/ra);
  40.     printf("Time Constant %u\n",ca);
  41.     sbsettc(ca);
  42.     spkon();
  43.     while(dLen)
  44.     {
  45.         if(dLen>65000) la=65000; else la=dLen;
  46.         dLen-=la;
  47.         fread(aligned,1,la,fp);
  48.         sbplay(la);
  49.         printf("%lu Samples\n",la);
  50. //      while(dmacount()!=0xFFFF)
  51.         dmastatus();
  52.         while(!dmastatus())
  53.         {
  54.             if(kbhit())
  55.             {
  56.                 sbhaltdma();
  57.                 getch();
  58.                 dLen=0;
  59.                 break;
  60.             }
  61.         }
  62.     }
  63.     spkoff();
  64. }
  65. //------------------------------------------------------------------------------
  66. // Copyright (c) David Welch, 1993
  67. //------------------------------------------------------------------------------
  68.  
  69.